""" Viewlet 
"""

from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from plone.app.layout.viewlets.common import ViewletBase
from Products.CMFCore.utils import getToolByName

class HighlightEventViewlet(ViewletBase):
    """
    """
    index = ViewPageTemplateFile('highlight_event.pt')

    def getHighlightEvent(self):
        """ Returns the highlight event
        """
        catalog = getToolByName(self.context, 'portal_catalog')
        query = {
            'portal_type': 'News Item',
            'review_state': 'published',
            'sort_on': 'modified',
            'sort_order': 'reverse',
        }

        results = catalog(**query)

        if results:
            return results[0]
        
        return []
